Skip to main content

Camera Activity

The Camera Activity allows the user to either capture a photo or scan a QR code, depending on the specific requirements of the workflow.

Inputs

The CameraActivityOptions expects the following properties:

  • Title (string): A heading to indicate the purpose of the camera activity.
  • CameraType (string): Indicates the type of camera action to be performed:
    • "Photo": For capturing a photo.
    • "QR": For scanning a QR code.

Example Input

{
"title": "Take a Profile Picture",
"cameraType": "Photo"
}

Example Code

cameraActivity: async (data: CameraActivityOptions) => {
console.log("Camera Activity:", data);

if (data.cameraType === "QR") {
return await new Promise<{ action: WorkflowActivityUserAction; result: string }>((resolve) => {
RootNavigation.navigate("ScanCodeModal", {
onBarcodeResult: (qrData: string) => {
resolve({
action: WorkflowActivityUserAction.OK,
result: qrData,
});
},
});
});
} else {
return await new Promise<{ action: WorkflowActivityUserAction; result: string }>((resolve) => {
RootNavigation.navigate("CameraScreen", {
onPhotoTaken: (photoUri: string) => {
resolve({
action: WorkflowActivityUserAction.OK,
result: photoUri,
});
},
payload: { Title: data.title, CameraType: data.cameraType },
});
});
}
};

Handling and Layout

When the user navigates to the Camera Activity, the layout includes:

  1. Title: Displays the purpose of the camera action (e.g., "Take a Profile Picture").

  2. Camera Type:

    • QR Scanner: Opens a QR scanner that processes the scanned QR code and returns its data.
    • Photo Capture: Opens the camera to take a picture, returning the image's URI as a base64-encoded string.
  3. Action Flow:

    • For QR Scanner: When a QR code is successfully scanned, it returns the QR data.
    • For Photo Capture: When a photo is captured, it returns the photo’s URI or data in base64 format.

Output

The output for the Camera Activity depends on the user's interaction:

  • For QR Scanner:

    {
    action: WorkflowActivityUserAction.OK,
    result: "scannedQRCodeData" // The scanned QR code data as a string
    }
  • For Photo Capture:

    {
    action: WorkflowActivityUserAction.OK,
    result: "base64EncodedImage" // Captured photo in base64 string format
    }
  • If the user cancels:

    {
    action: WorkflowActivityUserAction.Cancel,
    result: ""
    }
X

Graph View